function form(curPage) {
	document.getElementById('curPage').value = curPage;
	//var f = document.getElementById(document.getElementById("pagerFormName").value);
	//f.submit();
	var url = $("#APP_ROOT_PATH").val() + $("#pageUrl").val() + "?curPage=" + $("#curPage").val();
	alert(url);
	window.location.href = url;
}

var count = document.getElementById('totalRows').value;
var pageSize = document.getElementById('pageSize').value;
var currentPage = document.getElementById('curPage').value;

if (currentPage == null) {
	currentPage = 1;
	} else {
		currentPage = parseInt(currentPage);
}

var pc = Math.ceil(count/pageSize);

var pageCount = (pc == 0)?1:pc;

if (currentPage <= pageCount && count > 0) {
	var pageStr = "";
	var breakPage = 9;
	var currentPosition = 4;
	var breakSpace = 2;
	var maxSpace = 4;
	
	var prevNum = currentPage-currentPosition;
	var nextNum = currentPage+currentPosition;
    		
	if (prevNum < 1) prevNum = 1;
	if (nextNum > pageCount) nextNum = pageCount;
	pageStr += (currentPage == 1)?'<span class="prev">&lt; &#21069;&#39029;</span>':'<span class="prev">&lt; <a href="javascript:void(0)" onclick="form('+(currentPage-1)+');return false;">&#21069;&#39029;</a></span>';
	
	if (prevNum - breakSpace > maxSpace) {
		for(i = 1; i <= breakSpace; i++) 
			pageStr += '<a href="javascript:void(0)" onclick="form('+i+');return false;">'+i+'</a>';
		pageStr += '<span class="break">...</span>';
		
		for (i = pageCount - breakPage + 1; i < prevNum; i++)
			pageStr += '<a href="javascript:void(0)" onclick="form('+i+');return false;">'+i+'</a>';
	} else {
		for(i = 1; i < prevNum; i++)
			pageStr += '<a href="javascript:void(0)" onclick="form('+i+');return false;">'+i+'</a>';
	}
	
	for(i = prevNum; i <= nextNum; i++) {
		pageStr += (currentPage==i)?'<span class="thispage">'+i+'</span>':'<a href="javascript:void(0)" onclick="form('+ i +');return false;">'+i+'</a>';
    }
    		
	if (pageCount - breakSpace - nextNum + 1 > maxSpace) {
		for(i = nextNum + 1; i<= breakPage; i++)
			pageStr += '<a href="javascript:void(0)" onclick="form('+i+');return false;">'+i+'</a>';
		pageStr += '<span class="break">...</span>';
		for(i= pageCount - breakSpace + 1; i<= pageCount; i++)
			pageStr += '<a href="javascript:void(0)" onclick="form('+i+');return false;">'+i+'</a>';
	} else {
		for (i = nextNum + 1; i<= pageCount; i++)
			pageStr += '<a href="javascript:void(0)" onclick="form('+i+');return false;">'+i+'</a>';
	}
	
	pageStr += (currentPage==pageCount)?'<span class="next">&#21518;&#39029;&gt;</span>':'<span class="next"><a href="javascript:void(0)" onclick="form('+(currentPage+1)+');return false;">&#21518;&#39029;</a> &gt;</span>';
	document.getElementById("pagebar").innerHTML = pageStr + "<span class='count'>(共  " + count +" 条)</span>";
}